#include <iostream>

using namespace std;
class Dog
{
public:
	Dog(int _age,float _weight)
	{
		age=_age;
		weight=_weight;
	}
	Dog()
	{
		
	}
	//对加法进行运算符重载  是Dog的成员函数
	Dog operator+(Dog &otherdog)
	{
		//程序员自己实现加法运算的重载
		cout<<"加法运算重载"<<endl;
		//定义Dog的临时对象
		Dog temp;
		temp.age=this->age+otherdog.age;
		return temp;
	}
	void show()
	{
		cout<<"age  "<<age<<endl;
	}
private:
	int age;
	float weight;
};
int main()
{
	Dog dog1(5,50.2);
	Dog dog2(4,42.3);
	//写法一   采用了运算符号本来的语法写法
	//Dog dog3=dog1+dog2;
	//写法二  采用函数调用的写法
	Dog dog3=dog1.operator+(dog2);
	dog3.show();
	//cout<<dog3<<endl;
}